package io.renren.modules.sys.controller;

import io.renren.common.utils.ConstantUtils;
import io.renren.common.utils.R;
import io.renren.common.utils.UploadUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @program: stf
 * @description: 后端上传
 * @author: Custom
 * @create: 2018-11-04 21:58
 **/
@RestController
public class SysUploadController {

    //图片上传
    @RequestMapping(value = "/upload/img", method = RequestMethod.POST)
    public R upload(MultipartFile[] img, HttpSession session, HttpServletRequest request, HttpServletResponse response, @RequestParam int type) throws IOException {
        R uploadImage = UploadUtils.uploadImage(img, ConstantUtils.imageUrlPath, type);
        return uploadImage;

    }

}
